from time import sleep
from appium.webdriver.common.appiumby import AppiumBy
from common.base_page import BasePage


class PlayCompetition(BasePage):
    # 模拟炒股
    imitate_loc = (AppiumBy.XPATH, '//android.widget.ImageView[@bounds="[411,1491][489,1569]"]')
    # 比赛
    competition_loc = (AppiumBy.XPATH, '//android.widget.TextView[@text=" 比赛 "]')
    # 点击搜索文本框
    stockSearch_loc = (AppiumBy.ID, 'com.jhss.youguu:id/et_stock_search')
    # 输入比赛名称
    inputName_loc = (AppiumBy.ID, 'com.jhss.youguu:id/et_stock_search')
    # 获取文本
    nameNum = (AppiumBy.ID, 'com.jhss.youguu:id/tv_match_name')

    def play(self):
        self.click_ele(self.imitate_loc)
        self.click_ele(self.competition_loc)
        self.click_ele(self.stockSearch_loc)
        self.send_keys(self.inputName_loc, '2104A')
        sleep(5)
